﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entity.ProjectEnt;
using ZFine.Application.Project;
using ZFine.Code;
using ZFine.Web;

namespace Logiv.WEB.Areas.Project.Controllers
{
    public class CustomerAndThingsNameController : BaseController
    {

        public CustomerAndThingsNameApp serverApp = new CustomerAndThingsNameApp();
        #region 品名
        public ActionResult ThingsNameIndex()
        {
            return View();
        }

        public ActionResult ThingsNameForm()
        {
            return View();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="key">类型</param>
        /// <param name="txt_keyword">能否放行</param>
        /// <returns></returns>
        public ActionResult GetGridJson(Pagination pagination,string key,bool? txt_keyword)
        {
            try
            {
                var reuslt = serverApp.GetList(key, txt_keyword);
                var result = (from num in reuslt
                              select new CustomerAndThingsNameEntity
                    {
                        F_Id = num.F_Id,
                        Name = num.Name,
                        Remark=num.Remark,
                                  AllowFangxing= num.AllowFangxing
                              }).ToList();
                var data = new
                {
                    rows = result,
                    total = pagination.total,
                    page = pagination.page,
                    records = pagination.records
                };
                return Content(data.ToJson());

            }
            catch (Exception ex)
            {
                return null;
            }

        }


        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitForm(CustomerAndThingsNameEntity ServerEntity, string keyValue)
        {
            serverApp.SubmitForm(ServerEntity, keyValue);
            return Success("操作成功！");
        }

        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitFormCustomer(CustomerAndThingsNameEntity ServerEntity, string keyValue)
        {
            serverApp.SubmitFormCustomer(ServerEntity, keyValue);
            return Success("操作成功！");
        }

        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitFormCarBoxType(CustomerAndThingsNameEntity ServerEntity, string keyValue)
        {
            serverApp.SubmitFormCarBoxType(ServerEntity, keyValue);
            return Success("操作成功！");
        }

        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            serverApp.DeleteForm(keyValue);
            return Success("删除成功");
        }


        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = serverApp.GetForm(keyValue);
            return Content(data.ToJson());
        }
        #endregion


        #region 客户

        public ActionResult CustomerIndex()
        {
            return View();
        }
        public ActionResult CustomerForm()
        {
            return View();
        }

        #endregion

        #region 箱主

        public ActionResult CarboxTypeIndex()
        {
            return View();
        }
        public ActionResult CarboxTypeForm()
        {
            return View();
        }



        #endregion
    }
}